package com.ruoyi.common.convert;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;

/**
 * 将数组转为字符串
 */
public class ArrayToJsonDeserializer extends JsonDeserializer<String> {
    @Override
    public String deserialize(JsonParser p, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
        String res = p.getCodec().readTree(p).toString();

        System.out.println("将数组转为字符串" + res);
        return res;
//        return res.replace("\"", "");
    }
}
